from threading import Thread
import time

xianglong = -1


def task(arg):
    global xianglong
    xianglong = arg
    time.sleep(2)  # 没有遇到耗时操作则可以正操执行0-9 ,遇到耗时操作这样就会出错
    print(xianglong)


for i in range(10):
    t = Thread(target=task, args=(i,))
    t.start()

"""
9
9
999
9
9
9
9
9
进程已结束，退出代码为 0
"""
